<!DOCTYPE html>
<html xmlns:v-bind="http://www.w3.org/1999/xhtml">
<head>
    <title>系统用户</title>
    <script src="/statics/libs/jquery.min.js"></script>
    <script src="/statics/libs/vue.min.js"></script>
    <link rel="stylesheet" href="/statics/plugins/element-ui/lib/theme-chalk/index.css">
    <script src="/statics/plugins/element-ui/lib/index.js"></script>
</head>
<style>
    /*解决Vue刷新一瞬间出现样式未加载完或者出现Vue代码问题*/
    [v-cloak]{
        display: none;
    }
</style>
<body>
<div id="cwapp" v-cloak>
    <div v-show="showList">
        <el-button-group>
            <el-col :span="8">
                <el-input v-model.trim="q.username" @keyup.enter="query" placeholder="用户名"></el-input>
            </el-col>
            <el-button @click="query">查询</el-button>
            <el-button type="primary" @click="add">新增</el-button>
            <el-button type="primary" @click="update">修改</el-button>
            <el-button type="danger" @click="del">删除</el-button>
        </el-button-group>

        <el-table
                ref="multipleTable"
                :data="page.list"
                tooltip-effect="dark"
                style="width: 100%"
                @selection-change="handleSelectionChange">
            <el-table-column
                    type="selection">
            </el-table-column>
            <el-table-column
                    prop="userId"
                    label="用户id">
            </el-table-column>
            <el-table-column
                    prop="username"
                    label="用户名">
            </el-table-column>
            <el-table-column
                    prop="roleName"
                    label="角色"
                    show-overflow-tooltip>
            </el-table-column>
            <el-table-column
                    prop=""
                    label="操作">
                <template slot-scope="scope">
                    <el-link type="primary" v-if="scope.row.roleId===3" :underline="false" @click="selectCompany(scope.row)">分配公司</el-link>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="page.currPage"
                :page-sizes="[5, 10, 15, 20]"
                :page-size="page.pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="page.totalCount"
                style="text-align: center">
        </el-pagination>

    </div>

    <el-card class="box-card" v-show="!showList" style="width: 35%">
        <div slot="header" class="clearfix">
            <span>{{title}}</span>
        </div>
        <el-form :model="user" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
            <el-form-item label="用户名" prop="username">
                <el-input v-model="user.username" auto-complete="new-password"></el-input>
            </el-form-item>
            <el-form-item label="姓名" prop="chineseName">
                <el-input v-model="user.chineseName" auto-complete="new-password"></el-input>
            </el-form-item>
            <el-form-item label="密码" prop="password">
                <el-input type="password" v-model="user.password" auto-complete="new-password"></el-input>
            </el-form-item>
            <el-form-item label="角色" prop="roleId">
                <el-radio-group v-model="user.roleId">
                    <el-radio v-for="role in roleList" :label="role.roleId">{{role.roleName}}</el-radio>
                </el-radio-group>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="saveOrUpdate">确定</el-button>
                <el-button @click="loadPage(false)">返回</el-button>
            </el-form-item>
        </el-form>
    </el-card>
    <el-dialog title="选择公司" :visible.sync="showCompanyList">
        <el-form>
            <el-form-item label="公司列表">
                <el-select v-model="companyId" @change="chooseCompany" placeholder="请选择">
                    <el-option  v-for="item in companyList" :key="item.id" :label="item.name" :value="item.id"></el-option>
                </el-select>
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button @click="showCompanyList = false">取 消</el-button>
            <el-button type="primary" @click="setCompany()">确 定</el-button>
        </div>
    </el-dialog>

</div>

<script src="/statics/js/modules/sys/user.js?_${.now?long}"></script>
</body>
</html>
